/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InventoryState.java
 *
 * Created on 12 Apr 11, 19:02:09
 */

package plantmon.states;

import java.awt.Font;
import java.util.ArrayList;
import javax.swing.JLabel;
import javax.swing.JPanel;
import plantmon.entity.Inventory;
import plantmon.entity.movingObject.Player;
import plantmon.entity.movingObject.PulmosisLand;

/**
 *
 * @author asus
 */
public class InventoryState extends ParentState {
    Player player;
    /** Creates new form InventoryState */
    public InventoryState(Object[] args) {
        super();
        ID = INVENTORY;
        if (args[0] instanceof Player)
            this.player = (Player)args[0];
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jTabbedPane6 = new javax.swing.JTabbedPane();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        Pulmosis = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();

        setMaximumSize(new java.awt.Dimension(640, 480));
        setMinimumSize(new java.awt.Dimension(640, 480));
        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(640, 480));

        jTabbedPane6.setName("jTabbedPane6"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(new java.awt.GridLayout(4, 4));
        farm = Game.instance().getInventory().getFarmItem();
        for (int i=0; i<farm.getSize(); i++){
            jPanel1.add(new JLabel(farm.getItem(i).getName()+" "+farm.getJumlah(i)));
//            JPanel a = farm.getItem(i).get_Info();
//            JLabel label =new JLabel("Jumlah Barang: "+farm.getJumlah(i));
//            label.setFont(new Font("Times New Roman", Font.BOLD, 16));
//            label.setBounds(120,60,150,30);
//            a.add(label);
//            jPanel1.add(a);
        }
        jTabbedPane1.addTab("Farm Item", jPanel1); // NOI18N

        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setLayout(new java.awt.GridLayout(4, 4));
        farm = Game.instance().getInventory().getFoodItem();
        for (int i=0; i<farm.getSize(); i++){
//            jPanel2.add(new JLabel(farm.getItem(i).getName()+" "+farm.getJumlah(i)));
            JPanel a = farm.getItem(i).get_Info();
            JLabel label =new JLabel("Jumlah Barang: "+farm.getJumlah(i));
            label.setFont(new Font("Times New Roman", Font.BOLD, 16));
            label.setBounds(120,60,150,30);
            a.add(label);
            jPanel2.add(a);
            
        }
        jTabbedPane1.addTab("Food Item", jPanel2); // NOI18N

        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.setLayout(new java.awt.GridLayout(4, 4));
        farm = Game.instance().getInventory().getWarItem();
        for (int i=0; i<farm.getSize(); i++){
//            jPanel3.add(new JLabel(farm.getItem(i).getName()+" "+farm.getJumlah(i)));
            JPanel a = farm.getItem(i).get_Info();
            JLabel label =new JLabel("Jumlah Barang: "+farm.getJumlah(i));
            label.setFont(new Font("Times New Roman", Font.BOLD, 16));
            label.setBounds(120,60,150,30);
            a.add(label);
            jPanel3.add(a);
        }
        jTabbedPane1.addTab("War Item", jPanel3); // NOI18N

        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.setLayout(new java.awt.GridLayout(4, 4));
        farm = Game.instance().getInventory().getArmorItem();
        for (int i=0; i<farm.getSize(); i++){
//            jPanel4.add(new JLabel(farm.getItem(i).getName()+" "+farm.getJumlah(i)));
            JPanel a = farm.getItem(i).get_Info();
            JLabel label =new JLabel("Jumlah Barang: "+farm.getJumlah(i));
            label.setFont(new Font("Times New Roman", Font.BOLD, 16));
            label.setBounds(120,60,150,30);
            a.add(label);
            jPanel4.add(a);
        }
        jTabbedPane1.addTab("Armor", jPanel4); // NOI18N

        jTabbedPane6.addTab("Item", jTabbedPane1); // NOI18N

        Pulmosis.setName("Pulmosis"); // NOI18N
        Pulmosis.setLayout(new java.awt.GridLayout(15, 4));
        pulmo = Game.instance().getStory().getPulmosis();
        for (PulmosisLand p:pulmo) {
            Pulmosis.add(new JLabel(""+p.getName()));
        }
        jTabbedPane6.addTab("Pulmosis", Pulmosis); // NOI18N

        jLabel1.setText("Money"); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jButton1.setText("Return"); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel2.setText(String.valueOf(Game.instance().getMoney()));
        jLabel2.setName("jLabel2"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 418, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(27, 27, 27))
            .addComponent(jTabbedPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 403, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(22, 22, 22)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jButton1))
                .addContainerGap())
        );
    }// </editor-fold>

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        Game.instance().returnTo();
    }


    // Variables declaration - do not modify
    private javax.swing.JPanel Pulmosis;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private Inventory farm;
    private ArrayList<PulmosisLand> pulmo;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane6;
    // End of variables declaration

}
